home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / assemblr / library / sampler0 / mirror2.asm < prev    next >
Assembly Source File  |  1986-04-11  |  3KB  |  189 lines

  1. code    segment    para    public
  2.     assume    cs:code
  3.  
  4. steal_int    macro    int_num,subst_int,old_int
  5.     mov    bx,int_num * 4
  6.     mov    ax,word ptr es:[bx]
  7.     mov    word ptr old_int, ax
  8.     mov    ax,word ptr es:[bx+2]
  9.     mov    word ptr old_int[2], ax
  10.     mov    word ptr es:[bx], offset subst_int
  11.     mov    word ptr es:[bx+2], cs
  12.     endm
  13.  
  14. IntVecs    segment    at    0
  15.     org    10h * 4
  16. int_10        dd    ?
  17.  
  18.     org    043h*4
  19. grx_set    label    dword
  20.  
  21.     org    0450h
  22. cursor_posn    dw    ?
  23.  
  24. IntVecs    ends
  25.  
  26.     org    2Ch
  27. environment    label    word
  28.  
  29.     org    5CH
  30. real_int_10    dd    ?        ; video handler
  31. save_dx        dw    ?
  32. old_cursor_posn    dw    ?
  33.  
  34.     org    100h
  35. start:    jmp    setup
  36.  
  37.     assume    ds:nothing, es:nothing
  38.  
  39. handle_10    proc    far
  40.     cmp    ah,02h            ; check for set cursor position
  41.     jnz    not_set_cursor
  42.  
  43.     mov    save_dx,dx
  44.     mov    ah,79
  45.     sub    ah,dl
  46.     mov    dl,ah
  47.     mov    ah,02h            ; locate cursor at mirrored position
  48.     pushf
  49.     call    real_int_10
  50.  
  51.     push    bx
  52.     push    es
  53.     xchg    save_dx,dx
  54.  
  55.     xor    bx,bx
  56.     mov    es,bx
  57.     assume    es:IntVecs
  58.  
  59.     mov    cursor_posn,dx        ; but save cursor at true position
  60.  
  61.     pop    es
  62.     pop    bx
  63.     xchg    dx,save_dx
  64.     iret
  65.  
  66. not_set_cursor:
  67.     cmp    ah,09h            ; check for write character
  68.     jz    write_character
  69.     jmp    do_int_10
  70.  
  71. write_character:
  72.     push    bx
  73.     push    es
  74.  
  75.     xor    bx,bx
  76.     mov    es,bx
  77.     assume    es:IntVecs
  78.  
  79.     mov    bx,cursor_posn
  80.     mov    old_cursor_posn,bx
  81.     mov    ah,79            ; get mirrored position
  82.     sub    ah,bl
  83.     mov    bl,ah
  84.     mov    cursor_posn,bx        ; save it and write character
  85.     mov    ah,09h
  86.  
  87.     pop    es
  88.     pop    bx
  89.     pushf
  90.     call    real_int_10
  91.  
  92.     push    bx
  93.     push    es
  94.  
  95.     xor    bx,bx
  96.     mov    es,bx
  97.     assume    es:IntVecs
  98.     mov    bx,old_cursor_posn
  99.     mov    cursor_posn,bx        ; save the real cursor position
  100.     pop    es
  101.     pop    bx
  102.     iret
  103.  
  104. do_int_10:
  105.     pushf                ; fake an interrupt
  106.     call    real_int_10
  107.     iret
  108. handle_10    endp
  109.  
  110. handler_end    label    byte
  111. HANDLE_LEN    equ    $ - handle_10
  112.  
  113. font    label    word
  114.     db    14*256    dup(?)
  115.  
  116.     assume    ds:code,es:nothing
  117. steal    proc    far
  118. setup:
  119.     mov    es,environment        ; free environment area
  120.     mov    ax,4900h
  121.     int    21h
  122.  
  123.     mov    dl,14
  124.     mov    al,22h
  125.     mov    ah,11h
  126.     int    10h            ; grab regular 8x14 font
  127.  
  128.     xor    ax,ax
  129.     mov    es,ax
  130.     assume    es:IntVecs
  131.     lds    si,grx_set
  132.     push    cs
  133.     pop    es
  134.     assume    es:code
  135.  
  136.     mov    di,offset font
  137.     mov    cx,14*256
  138.     rep    movsb
  139.  
  140.     mov    si,offset font
  141.     push    cs
  142.     pop    ds
  143.     assume    ds:code
  144.  
  145.     mov    dx,14*256
  146. flip_chars:
  147.     mov    bl,ds:[si]
  148.     mov    cx,8
  149.     xor    al,al
  150. flip_a_character:
  151.     rcl    bl,1
  152.     rcr    al,1
  153.     loop    flip_a_character
  154.     mov    ds:[si],al
  155.     inc    si
  156.  
  157.     dec    dx
  158.     jnz    flip_chars
  159.  
  160.     xor    dx,dx
  161.     mov    cx,256
  162.     mov    bx,0E00h
  163.     mov    ax,1100h
  164.     mov    di,bp
  165.     mov    bp,offset font
  166.     push    cs
  167.     pop    es
  168.     int    10h            ; save the new font
  169.     mov    bp,di
  170.  
  171.     xor    ax,ax
  172.     mov    es,ax
  173.     assume    es:IntVecs
  174.     push    cs
  175.     pop    ds
  176.     assume    ds:code
  177.  
  178.     cli
  179.     steal_int    10h,handle_10,real_int_10
  180.     sti
  181.  
  182.     mov    dx,offset handler_end
  183.     int    27h
  184.  
  185. steal    endp
  186.  
  187. code    ends
  188.     end    start
  189.